package com.unione.map.view.fragment

import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.View.OnClickListener
import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.Navigation
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.BasePopupView
import com.lxj.xpopup.impl.LoadingPopupView
import com.unione.map.R
import com.unione.map.databinding.FragmentEditMapStep1Binding
import com.unione.map.databinding.FragmentEditMapStep2Binding
import com.unione.map.view.act.MainActivity
import com.unione.map.view.viewmodel.CreateMapStep1ViewModel
import com.unione.unione_protocol.robot_auto.bean.MapInfo
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class EditMapStep2Fragment : AppBaseFragment<FragmentEditMapStep2Binding>(), OnClickListener {

    private val viewModel: CreateMapStep1ViewModel by viewModels()
    private lateinit var loadingPopupView: LoadingPopupView
    private var mLoadingPopup: BasePopupView? = null
    private lateinit var mSelectMap:MapInfo

    companion object {
        const val TAG = "EditMapStep2Fragment"

    }

    override fun onCreateViewBinding(
        inflater: LayoutInflater,
        parent: ViewGroup?
    ): FragmentEditMapStep2Binding {
        return FragmentEditMapStep2Binding.inflate(inflater, parent, false)
    }

    override fun init() {
        initView()
        initListeners()
    }


    private fun initView() {

    }


    private fun initListeners() {
        binding.clVoice.setOnClickListener(this)
        binding.clHome.setOnClickListener(this)
        binding.clBack.setOnClickListener(this)
        binding.clEditMapBg.setOnClickListener(this)
        binding.clEditVirtualWall.setOnClickListener(this)
        binding.clEditRoute.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        super.onClick(v)
        if (v == null) return
        val nvController =
            Navigation.findNavController(
                requireActivity() as MainActivity,
                R.id.fragment_container_view
            )
        when (v.id) {
            R.id.btnNext -> {
                nvController.navigate(R.id.createMapStep2Fragment)
            }

            R.id.clEditMapBg -> {
                nvController.navigate(R.id.editMapBgFragment)
            }

            R.id.clEditVirtualWall -> {
                nvController.navigate(R.id.editMapVirtualWallFragment)
            }

            R.id.clEditRoute -> {
                nvController.navigate(R.id.editMapRouteFragment)
            }

        }
    }
}